uniform extern float4x4 gWVP;

// TODO: add effect parameters here.

struct VSInput
{
    float3 posL : POSITION0;
};

struct VSOutput
{
    float4 posH : POSITION0;
    float4 readablePosH : TEXCOORD0;
};

VSOutput DepthWriteVS(VSInput input)
{
    VSOutput output = (VSOutput)0;

    output.posH = mul(float4(input.posL, 1.0f), gWVP);
    output.readablePosH = output.posH;
    
    return output;
}

float4 DepthWritePS(VSOutput input) : COLOR0
{
	float d = 1.0f - input.readablePosH.z / input.readablePosH.w;
    return d;
}

technique DepthWrite
{
    pass Pass1
    {
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;

        VertexShader = compile vs_1_1 DepthWriteVS();
        PixelShader = compile ps_2_0 DepthWritePS();
    }
}
